import java.util.Vector;

/**
 * Class that represents a bill with methods to calculate the price of their products
 * @author JESUS
 *
 */
public class Bill {

	Vector Myproducts = new Vector();
	
	/**
	 * Method to add products to the vector
	 * @param p
	 */
	public void AddProduct (Product p){
		Myproducts.addElement(p);
	}
	
	/**
	 * This method calculates the total price of each product and returns the sum of that totals
	 * @return
	 */
	public float TotalBill (){
		float total = 0;
			for (int i = 0; i<Myproducts.size(); i++){
			Product P = ((Product)Myproducts.elementAt(i));
			total = total + P.TotalPrice(P);
		}
		return total;
	}
	
	/**
	 * This method "adds" the iva given to the total price of products in the vector
	 * @param iva
	 * @return
	 */
	public float AddIVA (float iva) {
		float result = 0;
		result = TotalBill() * iva;
		return result;
	}
}
